/**
 * 
 */
document.writeln("这是一个外部JavaScript文件");
console.log("调试开始");
var x = 10;
document.writeln("x = " + x);
console.log("调试结束")
// 弹出一个对话框，调试作用。能弹出说明以上代码都没问题，执行成功。
// alert(1)
var y = false;
document.writeln("布尔值：" + y);
document.writeln("<br/>")
document.writeln("y的类型是：" + typeof y)
document.writeln("<br/>");
var yStr = y.toString()
document.writeln("y转换为字符串yStr:" +yStr + "类型是：" + typeof(yStr));
document.writeln("<br/>");
var str = "321adb";
document.writeln("字符串转数字：" + parseInt(str));
document.writeln("<br/>");

// document.writeln(null.toString());  空类型转字符串会报错。
function print(param){
    document.writeln(param);
}
print("函数调用");
//计算两个值
function get() {
    var num1 = document.getElementById("num1").value
    var num2 = document.getElementById("num2").value
    num1 = parseFloat(num1)
    num2 = parseFloat(num2)
    var result = new Number(num1 + num2) 
    document.getElementById("result").value = result.toExponential()
}

function result() {
    var bossName = document.getElementById("bossName").value
    document.getElementById("huanghelou").value = "在" + document.getElementById("placeName").value  + bossName + "开了家叫做" + document.getElementById("companyName").value + "现在挣了很多钱。"
}

function showAlert() {
    alert("hello Javascript");
}

//判断今天是星期几
function whickWeekday() {
    var day = new Date().getDay()
    var today
    if (day == 0) {
        today = "星期天"
    }else if (day == 1) {
        today = "星期一"
    }else if (day == 2) {
        today = "星期二"
    }else if (day == 3) {
        today = "星期三"
    }else if (day == 4) {
        today = "星期四"
    }else if (day == 5) {
        today = "星期五"
    }else if (day == 6) {
        today = "星期六"
    }
    document.write("今天是：" + today)
}
//复利计算
function calculateFuli() {
    var qishizijin = document.getElementById("qishizijin").value
    var meinianshouyi = document.getElementById("meinianshouyi").value * 0.01
    var fulinianshu = document.getElementById("fulinianshu").value
    var meinianzhuijiazijin = document.getElementById("meinianzhuijiazijin").value


    var benjinhe = document.getElementById("benjinhe").value
    benjinhe = qishizijin + fulinianshu * meinianzhuijiazijin
    document.getElementById("benjinhe").value = benjinhe
   document.getElementById("lixihe").value = benjinhe * Math.pow(1+meinianshouyi, fulinianshu) - benjinhe
   document.getElementById("benxihe").value =  benjinhe * Math.pow(1+meinianshouyi, fulinianshu)
}
function replaceString() {
    var source = new String(document.getElementById("yuanzifucuan").value) ;
    var search = new String(document.getElementById("chaxun").value);
    var replace = new String(document.getElementById("tihuanwei").value);
    var reg = new RegExp(search, "g");
    var result = source.replace(reg, replace);
    document.getElementById("tihuanjieguo").value = result;
}


class Hero {
    constructor(name) {
        this.name = name;
        this.kill = function () {
            document.write(this.name + "正在杀敌<br>");
        };
    }
}
